package com.ruoyi.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manage.domain.IcdManage;
import com.ruoyi.manage.service.IIcdManageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ICD编码，手术字典信息，一般对接第三方Controller
 * 
 * @author liuyangyang
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/manage/icdmanage")
public class IcdManageController extends BaseController
{
    @Autowired
    private IIcdManageService icdManageService;

    /**
     * 查询ICD编码，手术字典信息，一般对接第三方列表
     */
    @PreAuthorize("@ss.hasPermi('manage:icdmanage:list')")
    @GetMapping("/list")
    public TableDataInfo list(IcdManage icdManage)
    {
        startPage();
        List<IcdManage> list = icdManageService.selectIcdManageList(icdManage);
        return getDataTable(list);
    }

    /**
     * 导出ICD编码，手术字典信息，一般对接第三方列表
     */
    @PreAuthorize("@ss.hasPermi('manage:icdmanage:export')")
    @Log(title = "ICD编码，手术字典信息，一般对接第三方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IcdManage icdManage)
    {
        List<IcdManage> list = icdManageService.selectIcdManageList(icdManage);
        ExcelUtil<IcdManage> util = new ExcelUtil<IcdManage>(IcdManage.class);
        util.exportExcel(response, list, "ICD编码，手术字典信息，一般对接第三方数据");
    }

    /**
     * 获取ICD编码，手术字典信息，一般对接第三方详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:icdmanage:query')")
    @GetMapping(value = "/{icdId}")
    public AjaxResult getInfo(@PathVariable("icdId") Long icdId)
    {
        return success(icdManageService.selectIcdManageByIcdId(icdId));
    }

    /**
     * 新增ICD编码，手术字典信息，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:icdmanage:add')")
    @Log(title = "ICD编码，手术字典信息，一般对接第三方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IcdManage icdManage)
    {
        return toAjax(icdManageService.insertIcdManage(icdManage));
    }

    /**
     * 修改ICD编码，手术字典信息，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:icdmanage:edit')")
    @Log(title = "ICD编码，手术字典信息，一般对接第三方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IcdManage icdManage)
    {
        return toAjax(icdManageService.updateIcdManage(icdManage));
    }

    /**
     * 删除ICD编码，手术字典信息，一般对接第三方
     */
    @PreAuthorize("@ss.hasPermi('manage:icdmanage:remove')")
    @Log(title = "ICD编码，手术字典信息，一般对接第三方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{icdIds}")
    public AjaxResult remove(@PathVariable Long[] icdIds)
    {
        return toAjax(icdManageService.deleteIcdManageByIcdIds(icdIds));
    }
}
